<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hrms.pojo.Employee"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工信息</title>
<script type="text/javascript" src="<%=path%>/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
	function isDel() {
		return confirm("确定删除吗！")
	}
	function checkName() {
		var emName = $("#emName").val();
		if ($.trim(emName) == "") {
			alert("姓名不能为空");
			return false;
		}
		return true;
	}
	function checkIdNumber() {
		var emIdNumber = $("#emIdNumber").val();
		var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
		if ($.trim(emIdNumber) == "" || reg.test(emIdNumber) === false) {
			alert("身份证输入不合法(18位数字组成,最后一位可以为X)");
			return false;
		}
		return true;
	}
	function checkinput() {
		var nubmer = $("#showPage").val();
		if (isNaN(nubmer)) {
			alert("请输入数字");
			$("#showPage").val("");
			return false;
		}
		return true;
	}
</script>
</head>
<body>
	<center>
		<jsp:include page="../top.jsp" flush="true"></jsp:include>
		<table width="800" height="48" border="0" cellpadding="0"
			cellspacing="0" background="<%=path%>/images/center1.jpg">
			<tr>
				<td valign="top">
					<table width="494">
						<tr>
							<td width="45" height="25"></td>
							<td width="437" valign="bottom"><a
								href="<%=path%>/admin/function"><b>主页</b></a>&gt;<a
								href="<%=path%>/emp/emp_f"><b>员工管理</b></a>&gt;<font
								color="#FF0000">员工信息列表</font></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>

		<table width="800" height="340" border="0" align="center"
			cellpadding="0" cellspacing="0"
			background="<%=path%>/images/center2.jpg">
			<tr>
				<td>
					<table width="700" align="center" cellpadding="10"
						cellspacing="0" style="margin-bottom: 20px;">
						<tr>
							<td>请输入名字：</td>
							<td>
								<form action="<%=path%>/emp/getname" method="post"
									onsubmit="return checkName()">
									<input type="text" name="emName" id="emName">&nbsp; <input
										type="submit" value="搜索">
								</form>
							</td>
						</tr>
						<tr>
							<td>请输入身份证号码：</td>
							<td>
								<form action="<%=path%>/emp/getidnum" method="post"
									onsubmit="return checkIdNumber()">
									<input type="text" name="emIdNumber" id="emIdNumber">&nbsp; <input
										type="submit" value="搜索">
								</form>
							</td>
						</tr>
					</table>
					<table width="700" border="1" align="center" cellpadding="0"
						cellspacing="0">
						<tr>
							<th class="style4"><div align="center">姓名</div></th>
							<th class="style4"><div align="center">性别</div></th>
							<th class="style4"><div align="center">年龄</div></th>
							<th class="style4"><div align="center">身份证号</div></th>
							<th class="style4"><div align="center">操作</div></th>
						</tr>
						<%
							Object obj = request.getAttribute("empList");
							Object objAll = session.getAttribute("empAll");

							List<Employee> empList = (List<Employee>) obj;
							List<Employee> empAll = (List<Employee>) objAll;
							//当前页
							Integer showPage = (Integer) session.getAttribute("showPage");
							//一页记录
							int pageSize = 4;
							int total = empAll.size();//总记录数
							//总页数
							int totalPage = (total % pageSize == 0 ? total / pageSize : total / pageSize + 1);
							if (showPage <= 1)
								showPage = 1;
							if (showPage > totalPage)
								showPage = totalPage;
							for (Employee emp : empList) {
						%>
						<tr>
							<td><%=emp.getEmName()%></td>
							<td><%=emp.getEmSex()%></td>
							<td><%=emp.getEmAge()%></td>
							<td><%=emp.getEmIdNumber()%></td>
							<td><a href="<%=path%>/emp/<%=emp.getEmId()%>/getid">详情</a>
								&nbsp; <a href="<%=path%>/emp/alter_emp?emId=<%=emp.getEmId()%>">修改</a>
								&nbsp; <a href="<%=path%>/emp/<%=emp.getEmId()%>/remove"
								onclick="return isDel()">删除</a></td>
						</tr>
						<%
							}
						%>
					</table>
				</td>
			</tr>
		</table>
		<div>
			<span>第<%=showPage%>页/共<%=totalPage%>页 <a
				href="<%=path%>/emp/limit?showPage=1">首页</a>&nbsp; <a
				href="<%=path%>/emp/limit?showPage=<%=showPage - 1%>">上一页</a> &nbsp;
				<a href="<%=path%>/emp/limit?showPage=<%=showPage + 1%>">下一页</a>&nbsp;
				<a href="<%=path%>/emp/limit?showPage=<%=totalPage%>">尾页</a></span>&nbsp;
			<form action="<%=path%>/emp/limit" onsubmit="return checkinput()">
				跳转到第<input type="text" name="showPage" id="showPage" size="1">页<input
					type="submit" value="GO">
			</form>
		</div>
		<jsp:include page="../down.jsp" flush="true" />
	</center>
</body>
</html>